#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#include <caml/mlvalues.h>
#include <caml/alloc.h>
#include <caml/memory.h>
#include <caml/fail.h>

value get_pass_c(value unit) {
  char *password;
    
  CAMLparam1(unit);
  password = getpass("");
  if (errno == ENXIO)
    goto fail;
  CAMLreturn (caml_copy_string (password));

 fail:
  caml_raise_constant(caml_named_value("Get_pass_failed"));
}
